package com.memo.controller;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.memo.R;
import com.memo.model.ListItemMainMenu;

public class MainListAdapter extends ArrayAdapter<ListItemMainMenu> {

    private Activity mContext;
    private ListItemMainMenu[] mListItem;

    public MainListAdapter(Context context, ListItemMainMenu[] listItemSimple) {
        super(context, R.layout.list_row_main_menu);
        this.mContext = (Activity) context;
        this.mListItem = listItemSimple;
    }
    
    @Override
    public int getCount() {
        return mListItem.length;
    }

    @Override
    public ListItemMainMenu getItem(int position) {
        return mListItem[position];
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row;
        row = inflater.inflate(R.layout.list_row_main_menu, null);
        ImageView ic_arrow = (ImageView) row.findViewById(R.id.list_row_arrow);
        ic_arrow.setImageResource(R.drawable.arrow_right);

        ImageView ic_item = (ImageView) row.findViewById(R.id.list_row_icon);
        ic_item.setImageResource(mListItem[position].getIcon());

        TextView txvTitle = (TextView) row.findViewById(R.id.list_row_title);
        txvTitle.setText(mListItem[position].getTitle());

        return row;
    }

    @Override
    public boolean isEnabled(int position) {
        return mListItem[position].isEnabled();
    }

}
